package com.hd.trans.db.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.alibaba.fastjson.annotation.JSONField;
import com.google.gson.annotations.SerializedName;
import com.hd.trans.homefun.EventCode;

import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.Generated;

@Entity
public class Limit4UseBean implements Parcelable {
    @Id(autoincrement = true)
    private Long id;

    @Property(nameInDb = "m_code")
    @JSONField(name = "m_code")
    @SerializedName("m_code")
    private int m_code;

    @Property(nameInDb = "limit4use_time")
    @JSONField(name = "time")
    @SerializedName("time")
    private Long time;


    @Property(nameInDb = "limit4use_count")
    @JSONField(name = "count")
    @SerializedName("count")
    private int count;


    protected Limit4UseBean(Parcel in) {
        if (in.readByte() == 0) {
            id = null;
        } else {
            id = in.readLong();
        }
        m_code = in.readInt();
        if (in.readByte() == 0) {
            time = null;
        } else {
            time = in.readLong();
        }
        count = in.readInt();
    }

    public Limit4UseBean(EventCode eventCode, Long time, int count) {
        this.m_code = eventCode.getCode();
        this.time = time;
        this.count = count;
    }

    @Generated(hash = 1935890635)
    public Limit4UseBean(Long id, int m_code, Long time, int count) {
        this.id = id;
        this.m_code = m_code;
        this.time = time;
        this.count = count;
    }

    @Generated(hash = 1908143690)
    public Limit4UseBean() {
    }


    public static final Creator<Limit4UseBean> CREATOR = new Creator<Limit4UseBean>() {
        @Override
        public Limit4UseBean createFromParcel(Parcel in) {
            return new Limit4UseBean(in);
        }

        @Override
        public Limit4UseBean[] newArray(int size) {
            return new Limit4UseBean[size];
        }
    };

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getTime() {
        return this.time;
    }

    public void setTime(Long time) {
        this.time = time;
    }

    public int getCount() {
        return this.count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public int getM_code() {
        return this.m_code;
    }

    public void setM_code(int m_code) {
        this.m_code = m_code;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {

        if (id == null) {
            parcel.writeByte((byte) 0);
        } else {
            parcel.writeByte((byte) 1);
            parcel.writeLong(id);
        }
        parcel.writeInt(m_code);
        if (time == null) {
            parcel.writeByte((byte) 0);
        } else {
            parcel.writeByte((byte) 1);
            parcel.writeLong(time);
        }
        parcel.writeInt(count);
    }

}
